package com.ly.blog2Word.controller;

import com.alibaba.fastjson.JSONObject;
import com.ly.blog2Common.core.http.ResponseMessage;
import com.ly.blog2Common.core.page.PageRequest;
import com.ly.blog2Word.dao.model.WordEssay;
import com.ly.blog2Word.service.WordEssayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: lyMaster
 * @time: 2020/7/17 19:16
 */
@RequestMapping("/essay")
@RestController
public class WordEssayController {

    @Value("${aaa}")
    String v;

    @Autowired
    private WordEssayService wordEssayService;

    @PostMapping(value="/save")
    public JSONObject save(@RequestBody WordEssay record) {
        return ResponseMessage.ok(wordEssayService.save(record));
    }

    @PostMapping(value="/delete")
    public JSONObject delete(@RequestBody List<WordEssay> records) {
        return ResponseMessage.ok(wordEssayService.delete(records));
    }

    @PostMapping(value="/findPage")
    public JSONObject findPage(@RequestBody PageRequest pageRequest) {
        return ResponseMessage.ok(wordEssayService.findPage(pageRequest));
    }

    @GetMapping(value="/findAll")
    public JSONObject findAll() {
        return ResponseMessage.ok();
    }

    @GetMapping(value="")
    public JSONObject test() {
        return ResponseMessage.ok(v);
    }


}
